<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>档案</title>
<base href="<?php echo base_url();?>" />
<link href="style/base.css" rel="stylesheet" type="text/css" />
<link href="style/common.css" rel="stylesheet" type="text/css" />
<link href="style/houtai.css" rel="stylesheet" type="text/css" />
<link href="style/yindao.css" rel="stylesheet" type="text/css" />
<link href="style/my.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script src="js/organictabs.jquery.js"></script>
<script type="text/javascript" src="js/Common.js"></script>
<script type="text/javascript" src="js/Validation.js"></script>
<script type="text/javascript" src="jscript/WdatePicker.js"></script>
<script type="text/javascript" src="js/jquery.form.js"></script>
<script type="text/javascript" src="js/jquery.blockUI.js"></script>
<script type="text/javascript">
$(function(){
    initSelected();
    $("#txtHigh").bind("blur",function(){checkSize("txtHigh")});
    $("#txtWeight").bind("blur",function(){checkSize("txtWeight")});
    $("#txtShoeSize").bind("blur",function(){checkSize("txtShoeSize")});
    $("#txtChestSize").bind("blur",function(){checkSize("txtChestSize")});
    $("#txtWaistSize").bind("blur",function(){checkSize("txtWaistSize")});
    $("#txtButtSize").bind("blur",function(){checkSize("txtButtSize")});
    loadUserInfo();
    $("#btnNext").bind("click",save);
});
function saveArchiveHead(src){
    var params = {headurl:src};
    $.ajax({
        type:"post",
        url:"index.php/login/saveArchiveHead",
        dataType:"json",
        data:params,
        success:function(data){

        }
    });
}
function loadUserInfo(){
    $.ajax({
        type:"post",
        url:"index.php/login/getUserInfo",
        dataType:"json",
        success:function(data){
            $("#txtHigh").val(data.high);
            $("#txtWeight").val(data.weight);
            $("#txtShoeSize").val(data.shoesize);
            $("#txtChestSize").val(data.chestsize);
            $("#txtWaistSize").val(data.waistsize);
            $("#txtButtSize").val(data.buttsize);
            setSelect("dlnature",data.worknature);
            setSelect("dltype",data.modeltype);
            setSelect("dlstyle",data.modelstyle);
            setSelect("dlhair",data.modelhair);
            setSelect("dlskin",data.modelskin);
            setSelect("dlbody",data.modelbody);
        }
    });
}
function setSelect(id,value){
    if(IsEmpty(value))
        return;
    $("#"+id).find("a").each(function(){
        $(this).removeClass("seled");
        var av = "/" + $(this).attr("value") +"/";
        if(value.indexOf(av)!=-1)
            $(this).trigger("click");
    });
}
function checkSize(id){
    var v = $("#"+id).val();
    if(IsEmpty(v)){
        SetError(id,"必填");
        return false;
    }
    if(!IsInt(v)){
        SetError(id,"必须为整数");
        return false;
    }
    if(v<=0 || v>260){
        SetError(id,"须界于1~260");
        return false;
    }
    SetOK(id);
    return true;
}
function checkSelect(id){

    if($("#"+id).find("a[class='seled']").length==0){
        SetError(id,"请至少选一项");
        return false;
    }
    ClearError(id);
    return true;
}
function getSelectId(id){
    var v = "";
    $("#"+id).find("a[class='seled']").each(function(){

        v+=$(this).attr("value")+"/";
    });
    return v;
}
function save(){
    if(checkSize("txtHigh")==false)
        return;
    if(checkSize("txtWeight")==false)
        return;
    if(checkSize("txtShoeSize")==false)
        return;
    if(checkSize("txtChestSize")==false)
        return;
    if(checkSize("txtWaistSize")==false)
        return;
    if(checkSize("txtButtSize")==false)
        return;
    if(checkSelect("dlnature")==false)
        return;
    if(checkSelect("dltype")==false)
        return;
    if(checkSelect("dlstyle")==false)
        return;
    if(checkSelect("dlhair")==false)
        return;
    if(checkSelect("dlskin")==false)
        return;
    if(checkSelect("dlbody")==false)
        return;


    var high = $("#txtHigh").val();
    var weight = $("#txtWeight").val();
    var shoesize = $("#txtShoeSize").val();
    var chestsize = $("#txtChestSize").val();
    var waistsize = $("#txtWaistSize").val();
    var buttsize = $("#txtButtSize").val();

    var worknature=getSelectId("dlnature");
    var modeltype = getSelectId("dltype");
    var modelstyle = getSelectId("dlstyle");
    var modelhair = getSelectId("dlhair");
    var modelskin = getSelectId("dlskin");
    var modelbody = getSelectId("dlbody");

    //alert(worknature+"-"+modeltype+"-"+modelstyle+"-"+modelhair+"-"+modelskin+"-"+modelbody);
    //return;


    var params = {
        high:high,
        weight:weight,
        shoesize:shoesize,
        chestsize:chestsize,
        waistsize:waistsize,
        buttsize:buttsize,
        worknature:worknature,
        modeltype:modeltype,
        modelstyle:modelstyle,
        modelhair:modelhair,
        modelskin:modelskin,
        modelbody:modelbody
    };
    var url = "index.php/login/saveArchiveTwo";
    $.ajax({
        type:"post",
        url:url,
        dataType:"json",
        data:params,
        success:function(data){
            if(data.ReturnCode==1){
                if($("#btnNext").attr("src") == "images/bc_inp.jpg"){
                    alert('保存成功');
                    window.location="<?php echo base_url();?>index.php/manage/marchive";

                }else{
                    window.location="<?php echo base_url();?>index.php/login/experience";
                }
            }else{
                alert('保存失败');
            }
        }
    });
}

//初始化性别选择样式
function initSelected(){
    //选中filter下的所有a标签，为其添加hover方法，该方法有两个参数，分别是鼠标移上和移开所执行的函数。
    $("dd a").hover(
        function () {
            $(this).addClass("seling");
        },
        function () {
            $(this).removeClass("seling");
        }
    );
    //选中filter下所有的dt标签，并且为dt标签后面的第一个dd标签下的a标签添加样式seled。(感叹jquery的强大)
    //$("dd a :first").attr("class", "seled"); /*注意：这儿应该是设置(attr)样式，而不是添加样式(addClass)，
    //                                   不然后面通过$("#filter1 a[class='seled']")访问不到class样式为seled的a标签。*/

    //为filter下的所有a标签添加单击事件
    $("#dlnature,#dlhair,#dlskin,#dlbody").find("a").click(function () {
        $(this).parents("dl").find("a").each(function () {
            //下面三种方式效果相同（第三种写法的内部就是调用了find()函数，所以，第二、三种方法是等价的。）
            //$(this).children("div").children("a").removeClass("seled");
            //$(this).find("a").removeClass("seled");
            $(this).removeClass("seled");
        });

        $(this).attr("class", "seled");
    });

    $("#dltype,#dlstyle").find("a").click(function () {
        $(this).toggleClass("seled");
    });

}
</script>
</head>
<body>
<?php
include 'header.php';
?>
<form id="formArchive" action="index.php/login/uploadImg" method="post"
      enctype="multipart/form-data">
<!-- 02 开始 -->
<div class="yindao_k">

<?php
if(!isset($ht))
    echo "<div class='yindao_bt'>
				<img src='images/yindao_02.jpg' />
				</div>";
?>



<!-- 模特档案 开始 -->
<div class="dangan">
    <table class="tablearchive">
        <tr>
            <td><span>身高(CM)：</span><input id="txtHigh" name=""
                                           style="width: 100px; height: 24px;" type="text" /></td>
            <td><span>体重(KG)：<input id="txtWeight" name=""
                                    style="width: 100px; height: 24px;" type="text" /></td>
            <td></span> <span>鞋码(MA)：<input id="txtShoeSize" name=""
                                            style="width: 100px; height: 24px;" type="text" /></span></td>
        </tr>
        <tr>
            <td><span>胸围(CM)：<input id="txtChestSize" name=""
                                    style="width: 100px; height: 24px;" type="text" /></span></td>
            <td><span>腰围(CM)：<input id="txtWaistSize" name=""
                                    style="width: 100px; height: 24px;" type="text" /></span></td>
            <td><span>臀围(CM)：<input id="txtButtSize" name=""
                                    style="width: 100px; height: 24px;" type="text" /></span></td>
        </tr>
    </table>

</div>
<!-- 模特档案 结束 -->

<!-- 选择代码 开始 -->
<div id="filter">
    <dl id="dlnature">
        <dt>
            <span>模特身份：</span>
        </dt>
        <dd>
            <div>
                <a value="1" class="seled">兼职模特</a>
            </div>
        </dd>
        <dd>
            <div>
                <a value="2">全职模特</a>
            </div>
        </dd>
    </dl>
    <dl id="dltype">
        <dt>
            <span>模特类型（多选）：</span>
        </dt>
        <dd>
            <div>
                <a value="1">平面/广告</a>
            </div>
        </dd>
        <dd>
            <div>
                <a value="2">T台走秀</a>
            </div>
        </dd>
        <dd>
            <div>
                <a value="3">车展/礼仪</a>
            </div>
        </dd>
        <dd>
            <div>
                <a value="4" class="seled">局部/内衣</a>
            </div>
        </dd>
    </dl>
    <dl id="dlstyle">
        <dt>
            <span>我的风格（多选）：</span>
        </dt>
        <dd>
            <div>
                <a value="1">性感</a>
            </div>
        </dd>
        <dd>
            <div>
                <a value="2">甜美</a>
            </div>
        </dd>
        <dd>
            <div>
                <a value="3">熟女</a>
            </div>
        </dd>
        <dd>
            <div>
                <a value="4">运动</a>
            </div>
        </dd>
        <dd>
            <div>
                <a value="5">清新</a>
            </div>
        </dd>
        <dd>
            <div>
                <a value="6">狂野</a>
            </div>
        </dd>
        <dd>
            <div>
                <a value="7">职业OL</a>
            </div>
        </dd>
        <dd>
            <div>
                <a value="8">欧美</a>
            </div>
        </dd>
        <dd>
            <div>
                <a value="9">日韩</a>
            </div>
        </dd>
        <dd>
            <div>
                <a value="10">民族</a>
            </div>
        </dd>
        <dd>
            <div>
                <a value="11" class="seled">传统</a>
            </div>
        </dd>
    </dl>
    <dl id="dlhair">
        <dt>
            <span>发型长度：</span>
        </dt>
        <dd>
            <div>
                <a value="1" class="seled">长发</a>
            </div>
        </dd>
        <dd>
            <div>
                <a value="2">中短发</a>
            </div>
        </dd>
        <dd>
            <div>
                <a value="3">短发</a>
            </div>
        </dd>
    </dl>
    <dl id="dlskin">
        <dt>
            <span>肤色：</span>
        </dt>
        <dd>
            <div>
                <a value="1" class="seled">苗条</a>
            </div>
        </dd>
        <dd>
            <div>
                <a value="2">标准</a>
            </div>
        </dd>
        <dd>
            <div>
                <a value="3">略胖</a>
            </div>
        </dd>
        <dd>
            <div>
                <a value="4">丰满</a>
            </div>
        </dd>
        <dd>
            <div>
                <a value="5">健美</a>
            </div>
        </dd>
    </dl>
    <dl id="dlbody">
        <dt>
            <span>体形：</span>
        </dt>
        <dd>
            <div>
                <a value="1" class="seled">苗条</a>
            </div>
        </dd>
        <dd>
            <div>
                <a value="2">标准</a>
            </div>
        </dd>
        <dd>
            <div>
                <a value="3">略胖</a>
            </div>
        </dd>
        <dd>
            <div>
                <a value="4">丰满</a>
            </div>
        </dd>
        <dd>
            <div>
                <a value="5">健美</a>
            </div>
        </dd>
    </dl>
</div>
<div class="clear"></div>

<?php
if(!isset($ht))
    print "<div class='yindao_inp'><a href='index.php/login/archive'><img id='btnPre' class='link'
						src='images/fhsyb_inp.jpg' /></a> <img id='btnNext' class='link'
								src='images/bcxyb_inp.jpg' /></div>";
else
    print "<div class='filter_inp'><img id='btnNext' class='link' src='images/bc_inp.jpg'></div>";
?>
<!-- 选择代码 结束 -->
</div>
<!-- 02 结束 -->
</form>

<!-- 页脚 开始 -->
<?php include 'footer.php';?>
<!-- 页脚 结束 -->
</body>
</html>


